package com.william.yun.yunliwuli.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.william.yun.yunliwuli.service.BindingService;
import com.william.yun.yunliwuli.service.CoreService;

public class BindingServiceImpl extends CoreService implements BindingService {
    /**
     * 绑定价签
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postBinding(JSONObject body, String token) {
        return postJsonResult(body.getJSONArray("procBindings"), token, BANDING.concat("?storeUuid=").concat(body.getString("storeUuid")));
    }

    /**
     * 删除标签
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject removeBinding(JSONObject body, String token) {
        return deleteJsonResult(body, token, REMOVE);
    }

    /**
     * 商品查询绑定标签及其所属门店
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubBindQuery(String mac, String token) {
        return postJsonResult(new JSONObject(), token, PUB_BIND_QUERY_URL.concat("?").concat("mac=").concat(mac));
    }

    /**
     * 更改商品、价签、模板绑定关系
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubBindUpdate(JSONObject body, String token) {
        return postJsonResult(body, token, PUB_BIND_UPDATE_URL);
    }

    /**
     * 订阅推送服务
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubUpdatePushUrl(JSONObject body, String token) {
        return postJsonResult(body, token, PUB_UPDATEPUSHURL_URL);
    }

    /**
     * 获取当前门店的价签列表
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubLabelQuery(JSONObject body, String token) {
        return postJsonResult(body, token, PUB_LABEL_QUERY_URL);
    }

    /**
     * 价签批量添加
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubLabelAdd(JSONObject body, String token) {

        return postJsonResult(body.getJSONArray("macs"), token, PUB_LABEL_ADD_URL.concat("?storeUuid=").concat(body.getString("storeUuid")));    }

    /**
     * 修改商品内容与模板绑定，灭灯点灯
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubBindingUpdateLED(JSONObject body, String token) {
        return postJsonResult(body, token, PUB_BINDING_UPDATE_LED_URL);
    }

    /**
     * 查询价签绑定具体信息
     *
     * @param body
     * @param token
     * @return
     */
    @Override
    public JSONObject postPubQueryLabelBindingMessage(JSONObject body, String token) {
        return postJsonResult(body, token, PUB_QUERYLABELBINDINGMESSAGE_URL);
    }


}
